import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useAuthStore = defineStore(
  'auth',
  () => {
    const token = ref<string | null>(null)
    const setToken = (tokenValue: string) => {
      token.value = tokenValue
    }
    const getToken = (): string | null => {
      return token.value
    }
    const delToken = () => {
      token.value = null
    }
    return {
      setToken,
      getToken,
      delToken,
    }
  },
  {
    persist: true,
  },
)
